package pwd.allen.plugin;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

/**
 *
 *
 *
 * @author 门那粒沙
 * @create 2022-03-13 15:46
 **/
/**
 * 指定 goalOne这个goal会执行本mojo，默认绑定在install阶段
 */
@Mojo(name = "goalOne", defaultPhase = LifecyclePhase.INSTALL)
public class MyMojo extends AbstractMojo {

    /**
     * pom中configuration标签中要用<param1></param1>
     * mvn命令中传参要用 -Dproperty=xxx
     */
    @Parameter(property = "property", defaultValue = "default")
    private String param1;

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        // 打印maven日志
        getLog().info(String.format("this is my plugin.your param1 is %s.", param1));
        // 控制台看不到
        System.out.println("sout");
    }
}
